<!DOCTYPE HTML>
<html>
<head>
    <title>首页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="" />
    <link href="/css/bootstrap.css" rel='stylesheet' type='text/css' />
    <link href="/css/style.css" rel="stylesheet" type="text/css" media="all" />
    <link href="/css/crg.css" rel="stylesheet" type="text/css" media="all" />
    <link rel="icon" href="/image/favicon.ico">
</head>
<body>
<!-- body-->
<div class="container">
    <div class="container">
        <div class="container_wrap">
            <div class="header_top">
                <div class="col-sm-3 logo"><a href="/" name="首页"><img src="/image/logo.png" alt=""/></a></div>
                <div class="col-sm-6 nav">
                </div>
                <div class="col-sm-3 header_right">
                </div>
                <div class="clearfix"> </div>
            </div>
            <div class="content">
                <div class="register">
                    <div class="col-md-6 login-left">
                        <div class="callbacks_container">
                         <img src="/image/banner.jpg" class="img-responsive" alt=""/>
                        </div>
                    </div>
                    <div class="col-md-6 login-right">
                        <div class="form-title">
                            <span class="title">18~60周岁均可申请</span>
                        </div>
                            <div class="form-name">
                                <span><input class="input-text fz-16" type="text" value="" placeholder="请输入您的姓名" id="customerName" name="name" maxlength="16"/><label>*</label></span>
                            </div>
                            <div class="form-phone">
                                <span><input class="input-text fz-16" type="text" value="" placeholder="请输入您的手机号码" id="phone" name="mobile" maxlength="11"/><label>*</label></span>
                            </div>
                        <div class="form-btn ">
                            <a href="javascript:void(0);" onclick="acc()" >立即申请</a>
                        </div>

                    </div>
                    <div class="clearfix"> </div>
                </div>
            </div>
        </div>
    </div>
<!-- footer-->
<div class="container">
    <footer id="footer">
        <div id="footer-3d">
            <div class="gp-container">
                <span class="first-widget-bend"></span>
            </div>
        </div>
        <div id="footer-widgets" class="gp-footer-larger-first-col">
            <div class="gp-container">
                <div class="footer-widget footer-1">
                    <div class="wpb_wrapper">
                        <img src="/image/f_logo.png" alt=""/>
                    </div>
                    <br>
                    <p>为广大消费者提供保单贷款业务.</p>
                    <p class="text">There are many variations of passages of Lorem Ipsum available, but the majority have suffered.</p>
                </div>
                <div class="footer_box">

                    <div class="col_1_of_3 span_1_of_3">
                        <h3>联系我们</h3>
                        <ul class="first">
                            <li><a href="#">微信群</a></li>
                            <li><a href="#">QQ群</a></li>
                            <li><a href="#">客户经理电话：131 2213 1880 (付)</a></li>
                        </ul>
                        <div class="copy">
                            <p>Copyright &copy; 2015-2018.36Fly All rights reserved.</p>
                        </div>
                    </div>
                    <div class="clearfix"> </div>
                </div>
                <div class="clearfix"> </div>
            </div>
        </div>
    </footer>
</div>
<!-- start plugins -->
<script type="text/javascript" src="/js/jquery-1.11.1.min.js"></script>
<link href='http://fonts.useso.com/css?family=Roboto+Condensed:100,200,300,400,500,600,700,800,900' rel='stylesheet' type='text/css'>
<script src="/js/responsiveslides.min.js"></script>
    <script type="text/javascript">
        function acc(){
            if(!isName($.trim($("#customerName").val()))){
                return false;
            }
            if(!isPoneAvailable($.trim($("#phone").val()))){
                return false;
            }
            $.ajax({
                    type:'POST',
                    url:'/json/add',
                    contentType: 'application/json;charset=utf-8',
                    data: JSON.stringify(GetJsonData()),
                    dataType:'json',
                    success:function (data) {
                        window.location.href="/cont/regdetail/"+data;
                    },
                    error:function () {
                        alert("提交失败！");
                    }
                }

            )

        }
        function GetJsonData() {
            var name = $.trim($("#customerName").val()); //姓名
            var phone= $.trim($("#phone").val()); //手机号
            var json = {
                "customerName": name,
                "phone":phone
            };
            return json;
        }

        function isPoneAvailable(phone) {
            if (!phone) { // 手机号码
                alert('请输入手机号码');
                return false;
            } else if (!phone.match(/^1(3|4|5|7|8)\d{9}$/)) {
                alert('请正确填写手机号码');
                return false;
            } else {
                var repeat = 0,
                    seque = 0;
                for (var i = 1; i < phone.length; i++) {
                    if (phone.charAt(i) == phone.charAt(i - 1)) {
                        repeat++;
                        if (repeat >= 5) {
                            alert('请正确填写手机号码');
                            return false;
                        }
                    } else {
                        repeat = 1;
                    }
                    if (phone.charAt(i) - phone.charAt(i - 1) == '1') {
                        seque++;
                        if (seque >= 6) {
                            alert('请正确填写手机号码');
                            return false;
                        }
                    } else {
                        seque = 1;
                    }
                }
            }
            return true;
        }

        function isName(name) {
            if (!name) { // 姓名校验
                alert('请输入姓名');
                return false;
            } else if (!name.match(/^[\u4e00-\u9fa5]{2,8}$/g)) {
                alert('姓名为2-8个汉字');
                return false;
            }
            return true;
        }
    </script>
</body>
</html>